home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / e.dxr / 00009_#E04 - gas station.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  8.0 KB  |  255 lines

  1. global gEnvironmentSound, gOBJECTSE, gObjects, gStates, NULLrect, gHotRects, gCursorlist, gWorld, sQTSPRITE, sQTCharSprite
  2.  
  3. on DoGasPINKey KeyNum
  4.   set gasStationObj to getaProp(gObjects, #GasStation)
  5.   set currentPIN to getaProp(gasStationObj, #GasPINDisplay)
  6.   if integerp(KeyNum) then
  7.     if getaProp(getaProp(gObjects, #GasStation), #State) = #on then
  8.       put string(KeyNum) after currentPIN
  9.       if getaProp(getaProp(gObjects, #screenInfo), #DisplayState) = #enterPellQty then
  10.         set charMax to 1
  11.       else
  12.         set charMax to 4
  13.       end if
  14.       set curPosition to the number of chars in currentPIN
  15.       if curPosition = charMax then
  16.         setGasPINKeyState(#enterPIN)
  17.       end if
  18.       set PINDispObj to getaProp(gObjects, value("#PINDisp" & curPosition))
  19.       set PINDispSprtNum to getaProp(PINDispObj, #SpriteNum)
  20.       set wchCst to value("#PD" & KeyNum)
  21.       set the castNum of sprite PINDispSprtNum to getAt(getaProp(getaProp(PINDispObj, #cast), wchCst), 1)
  22.       MakeDynamic(getaProp(PINDispObj, #RefName), #DisplayState, wchCst)
  23.       MakeDynamic(#GasStation, #GasPINDisplay, currentPIN)
  24.     end if
  25.   else
  26.     if KeyNum = #enter then
  27.       if getaProp(getaProp(gObjects, #screenInfo), #DisplayState) = #enterPIN then
  28.         if (currentPIN = getaProp(getaProp(gObjects, #GasStation), #validPIN)) or (currentPIN = 666) then
  29.           doValidGasPIN()
  30.         else
  31.           if currentPIN = EMPTY then
  32.           else
  33.             doInValidGasPIN()
  34.           end if
  35.         end if
  36.       else
  37.         set numPellets to getaProp(gasStationObj, #GasPINDisplay)
  38.         if (getaProp(gStates, #Credits) / 10) < numPellets then
  39.           doNotEnoughCash()
  40.         else
  41.           if numPellets = 0 then
  42.             doResetPINScreen(#enterPIN, 1)
  43.           else
  44.             if numPellets = EMPTY then
  45.             else
  46.               set fuelLevel to getaProp(getaProp(gObjects, #CarGasGauge), #fuelLevel)
  47.               if (numPellets + fuelLevel) < 6 then
  48.                 doIssuePellets(numPellets, fuelLevel)
  49.               else
  50.                 doExceedsCapacity()
  51.               end if
  52.             end if
  53.           end if
  54.         end if
  55.       end if
  56.     end if
  57.   end if
  58. end
  59.  
  60. on switchFeedback newState, onFrame
  61.   set displayObj to getaProp(gObjects, #screenInfo)
  62.   MakeDynamic(#screenInfo, #DisplayState, newState)
  63.   if onFrame = 1 then
  64.     set displaySprtNum to getaProp(displayObj, #SpriteNum)
  65.     set the castNum of sprite displaySprtNum to getaProp(getaProp(displayObj, #cast), newState)
  66.     updateStage()
  67.   end if
  68. end
  69.  
  70. on doExceedsCapacity
  71.   setGasPINKeyState(#off)
  72.   switchFeedback(#exceedsCapacity, 1)
  73.   Startthetimer(120, "doResetPINScreen #enterPellQty,TRUE", #screenInfo)
  74. end
  75.  
  76. on doNotEnoughCash
  77.   setGasPINKeyState(#off)
  78.   switchFeedback(#notEnoughCash, 1)
  79.   Startthetimer(120, "doResetPINScreen #enterPellQty,TRUE", #screenInfo)
  80. end
  81.  
  82. on doInValidGasPIN
  83.   setGasPINKeyState(#off)
  84.   switchFeedback(#unauthorizedPIN, 1)
  85.   Startthetimer(120, "doResetPINScreen #enterPIN,TRUE", #screenInfo)
  86. end
  87.  
  88. on doIssuePellets numPellets, fuelLevel
  89.   set newFuelLevel to integer(fuelLevel + numPellets)
  90.   MakeDynamic(#CarGasGauge, #fuelLevel, newFuelLevel)
  91.   changeGasGauge(newFuelLevel + 1, #false)
  92.   set Credits to getaProp(gStates, #Credits)
  93.   set totalCharge to 10 * numPellets
  94.   setaProp(gStates, #Credits, integer(Credits - totalCharge))
  95.   set feedbackState to value("#CredsChrge" & integer(totalCharge))
  96.   switchFeedback(feedbackState, 1)
  97.   Startthetimer(120, "doResetPINScreen #enterPIN,TRUE", #screenInfo)
  98.   playSound(string(numPellets & "Pell.aif"), #cast, 0)
  99. end
  100.  
  101. on setGasPINKeyState setState
  102.   if symbolp(setState) then
  103.     MakeDynamic(#GasStation, #State, setState)
  104.   else
  105.     alert("bad parameter passed to setShortKeyBoardState")
  106.   end if
  107. end
  108.  
  109. on displayGasPINFeedback inCastName
  110.   set feedbackCastNum to the number of cast inCastName
  111.   set shortFeedBackSprite to getaProp(getaProp(gObjects, #shortFeedback), #SpriteNum)
  112.   set the castNum of sprite shortFeedBackSprite to feedbackCastNum
  113.   updateStage()
  114. end
  115.  
  116. on doValidGasPIN
  117.   doResetPINScreen(#enterPellQty, 1)
  118. end
  119.  
  120. on doResetPINScreen whichState, onFrame
  121.   repeat with X = 1 to 4
  122.     set PINDispObj to getaProp(gObjects, value("#PINDisp" & X))
  123.     if onFrame = 1 then
  124.       set PDSprtNum to getaProp(PINDispObj, #SpriteNum)
  125.       set the castNum of sprite PDSprtNum to getAt(getaProp(getaProp(PINDispObj, #cast), #blank), 1)
  126.     end if
  127.     setaProp(getaProp(gObjects, value("#PINDisp" & X)), #DisplayState, #blank)
  128.   end repeat
  129.   setGasPINKeyState(#on)
  130.   MakeDynamic(#GasStation, #GasPINDisplay, EMPTY)
  131.   switchFeedback(whichState, onFrame)
  132. end
  133.  
  134. on doGasManQT
  135.   set clickCount to getaProp(getaProp(gObjects, #GasManQT), #clickCount) + 1
  136.   MakeDynamic(#GasManQT, #clickCount, clickCount)
  137.   pickGasMan(clickCount)
  138.   set the movieRate of sprite sQTCharSprite to 0
  139.   set the movieTime of sprite sQTCharSprite to 0
  140.   set the movieRate of sprite sQTCharSprite to 1
  141. end
  142.  
  143. on pickGasMan playCount
  144.   set gasManObj to getaProp(gObjects, #GasManQT)
  145.   if getaProp(gStates, #Credits) > 0 then
  146.     set droveOrTowed to getaProp(gasManObj, #droveOrTowed)
  147.     set curZone to getaProp(getaProp(gObjects, #carMap), #curZone)
  148.     set stationNum to getPos(getaProp(gasManObj, #stationLocs), integer(curZone))
  149.     if droveOrTowed = #drove then
  150.       if stationNum = 4 then
  151.         if playCount = 1 then
  152.           set State to #G4a
  153.         else
  154.           if playCount = 2 then
  155.             set State to #G4b
  156.           else
  157.             if playCount = 3 then
  158.               set State to #G4c
  159.             else
  160.               set State to #G4d
  161.             end if
  162.           end if
  163.         end if
  164.       else
  165.         if stationNum = 11 then
  166.           if playCount = 1 then
  167.             set State to #G11a
  168.           else
  169.             if playCount = 2 then
  170.               set State to #G11b
  171.             else
  172.               set State to #G11c
  173.             end if
  174.           end if
  175.         else
  176.           if stationNum = 12 then
  177.             if playCount = 1 then
  178.               set State to #G12a
  179.             else
  180.               if playCount = 2 then
  181.                 set State to #G12b
  182.               else
  183.                 set State to #G12c
  184.               end if
  185.             end if
  186.           else
  187.             set whichStation to value("#G" & stationNum)
  188.             if playCount = 1 then
  189.               set State to whichStation & "a"
  190.             else
  191.               set State to whichStation & "b"
  192.             end if
  193.           end if
  194.         end if
  195.       end if
  196.     else
  197.       set runoutCount to getaProp(getaProp(gObjects, #CarGasGauge), #runoutCount)
  198.       if runoutCount <> 4 then
  199.         if stationNum = 1 then
  200.           set State to #towedToG1
  201.           set E04gas01Count to getaProp(getaProp(gObjects, #GasManQT), #E04gas01Count)
  202.           if E04gas01Count = 0 then
  203.             set E04gas01Count to E04gas01Count + 1
  204.             MakeDynamic(#GasManQT, #E04gas01Count, E04gas01Count)
  205.           end if
  206.         else
  207.           set whichMov to random(8)
  208.           set State to value("#towed" & whichMov)
  209.         end if
  210.       else
  211.         if playCount = 1 then
  212.           set State to #Agent
  213.           set curCreds to getaProp(gStates, #Credits)
  214.           set curDebt to getaProp(gStates, #Debt)
  215.           if curDebt > curCreds then
  216.             set curDebt to curDebt - curCreds
  217.             set curCreds to 0
  218.           else
  219.             set curDebt to 0
  220.             set curCreds to curCreds - curDebt
  221.           end if
  222.           setaProp(gStates, #Credits, integer(curCreds))
  223.           setaProp(gStates, #Debt, curDebt)
  224.         else
  225.           set State to #empty
  226.         end if
  227.       end if
  228.     end if
  229.   else
  230.     if playCount = 1 then
  231.       set State to #noCredits1
  232.     else
  233.       set runoutCount to getaProp(getaProp(gObjects, #CarGasGauge), #runoutCount)
  234.       if runoutCount <> 4 then
  235.         set State to #noCredits2
  236.       else
  237.         set State to #empty
  238.       end if
  239.     end if
  240.   end if
  241.   if State = #empty then
  242.     abort()
  243.   end if
  244.   MakeDynamic(#GasManQT, #State, State)
  245.   MakeDynamic(#GasManQT, #DisplayState, getaProp(getaProp(gObjects, #GasManQT), #State))
  246.   if playCount > 1 then
  247.     DoCharacterMovie(#GasManQT)
  248.   end if
  249. end
  250.  
  251. on doGasLookLeft
  252.   Jumptokey(#E01)
  253.   CursorandUpdate()
  254. end
  255.